﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>添加代理商</title>
<link href="../js/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="../js/function.js" type="text/javascript"></script>
<script src="../js/base.js" type="text/javascript"></script>
<script src="../js/dialog.js" type="text/javascript"></script>
<script src="../js/jquery-form.js" type="text/javascript"></script>
<script src="../js/ajax-data.js" type="text/javascript"></script>
<style>body{ background-color: White;}</style>
</head>
<body class="mainbody">
<div class="navigation"><a href="javascript:history.go(-1);" class="back">后退</a>首页 &gt; 代理商 &gt; 添加代理商</div>
<div id="contentTab">
    <ul class="tab_nav">
        <li class="selected"><a onclick="tabs('#contentTab',0);" href="javascript:;">基本信息</a></li>
        <li style="display:none"><a onclick="tabs('#contentTab',1);" href="javascript:;">账户信息</a></li>
    </ul>
    <div class="tab_con" style="display:block;">
        <table class="form_table">
            <col width="150px"><col>
            <tbody>
    
            <tr>
                <th>微街秀ID：</th>
                <td>
                    <input type="text" id="user_id" name="user_id" onblur="get(this)" />
                    <label>* 6位以上的数字。</label>
                </td>
            </tr>
            <tr>
                <th>公司名：</th>
                <td>
                    <input type="text" id="sitename" name="sitename" />
                    <label>* 填写代理商的公司名称。</label>
                </td>
            </tr>
            <tr>
                <th>联系人：</th>
                <td>
                    <input type="text" id="linkman" name="linkman" />
                    <label>* 会员的真实姓名或昵称</label>
                </td>
            </tr>
            <tr>
                <th>电话：</th>
                <td>
                    <input type="text" id="phone" name="phone" />
                    <label>* 格式： 0755-88888888 </label>
                </td>
            </tr>
            <tr>
                <th>手机：</th>
                <td>
                    <input type="text" id="mobile" name="mobile" />
                    <label>* 11位以上数字。</label>
                </td>
            </tr>
            <tr>
                <th>邮 箱：</th>
                <td>
                    <input type="text" id="email" name="email" />
                    <label>* 例如：demo@711688.cn</label>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
     <div class="tab_con">
        <table class="form_table">
            <col width="150px"><col>
            <tbody>
            <tr>
                <th>账户金额：</th>
                <td>0元<label>*</label></td>
            </tr>
            </tbody>
        </table>
    </div>

    <div class="foot_btn_box" style=" text-align:left; padding-left:150px;">
        <input type="button" value="提 交" onclick="submits()" style="width:100px;"/>
    </div>
</div>
<script>
    function submits() {
        var param = { "user_id": $("#user_id").val(), "sitename": $("#sitename").val(), "linkman": $("#linkman").val(), "phone": $("#phone").val(), "mobile": $("#mobile").val(), "email": $("#email").val() };
        if (param.user_id == "") {
            Alert("请填写微街秀ID")
            return false;
        }
        if (param.sitename == "") {
            Alert("请填写公司名")
            return false;
        }
        if (param.linkman == "") {
            Alert("请填写联系人")
            return false;
        }
        if (param.phone == "" && param.mobile == "") {
            Alert("电话和手机至少填一项")
            return false;
        }
        $.post("../ajax/agent.ashx?add", param, function (data) {
            if (data.code == 0) {
                $("#user_id").val("");
                $("#sitename").val("");
                $("#linkman").val("");
                $("#phone").val("");
                $("#mobile").val("");
                $("#mobile").val("");
                $("#email").val("");
                Alert("添加成功");
            }
            else
                Alert(data.msg);
        }, "json");
    }


    var oldId = "";
    function get(obj) {        
        if (obj.value == "") return;
        if (oldId == obj.value) return;
        $("#sitename").val("");
        $("#linkman").val("");
        $("#phone").val("");
        $("#mobile").val("");
        $("#email").val("");
        $.get("../ajax/user.ashx?GetDetail", {"user_id": obj.value }, function (data) {
            oldId = obj.value;
            if (data.code != 0)
                Alert(data.msg);
            else {
                if (data.item == null) {
                    Alert("账号不存在")
                    return;
                }
                $("#sitename").val(data.item.nick_name);
                $("#linkman").val(data.item.nick_name);
                $("#mobile").val(data.item.phone);
                $("#email").val(data.item.email);
            }
        }, "json");
    }
</script>
</body>
</html>
